package org.adream.account.controller;

import javax.servlet.http.HttpServletRequest;

import org.adream.account.entity.UserEntity;
import org.adream.account.service.TagService;
import org.adream.account.service.UserService;
import org.adream.account.util.UserUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 个人信息修改 区别于用户管理，是用户自己修改
 * 
 * @author chenhaoyu
 */
@Controller
public class PersonalController {

	private final static Logger logger = LoggerFactory.getLogger(PersonalController.class);
	
	@Autowired
	UserService userService;

	@Autowired
	TagService tagService;

	/**
	 * 修改基本个人信息页面
	 * 
	 * @param uid
	 * @return
	 */
	@RequestMapping(value = "/personalChangeInfoPage")
	public ModelAndView userChangeInfo(String uid,HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("/personal/personal_change_info");
		UserEntity user = null;
		uid = uid == null ? UserUtil.getUidByRequest(request) : uid;
		user = userService.queryUserByUid(uid);
		mv.getModel().put("user", user);
		return mv;
	}

	/**
	 * 修改密码页面
	 * 
	 * @param uid
	 * @return
	 */
	@RequestMapping(value = "/personalChangePwdPage")
	public ModelAndView userChangePwd(String uid, HttpServletRequest request) {
		ModelAndView mv = new ModelAndView("/personal/personal_change_pwd");
		UserEntity user = null;
		uid = uid == null ? UserUtil.getUidByRequest(request) : uid;
		user = userService.queryUserByUid(uid);
		mv.getModel().put("user", user);
		return mv;

	}
}
